class Task53_2:
    def run(self, array):
        if len(array) == 0:
            return 0
        length = len(array)
        if array[length - 1] == length - 1:
            return length
        start = 0
        end = length
        while start < end:
            index = (start + end) // 2
            if array[index] > index:
                if index == 0 or array[index - 1] == index - 1:
                    return index
                else:
                    end = index
            else:
                start = index + 1
        return None     # should never happen
